<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>垂直居中</title>
    <style>

        div {
            height: 200px;
            width: 200px;
            margin: 200px auto;
            background-color: red;
            text-align: center;
            position: relative;
        }

        p {
            height: 50px;
            width: 200px;
            /*脱离了文档流*/
            position: absolute;
            top: 50%;
            /*自身有高度，需要偏移*/
            transform: translateY(-50%);
        }
    </style>
</head>
<body>

<div><p>你想说点啥</p></div>


</body>
</html>